package com.hermit.hermitmusicserver.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.hermit.hermitmusicserver.entity.ResultBO;
import com.hermit.hermitmusicserver.entity.TestEntity;
import com.hermit.hermitmusicserver.service.TestService;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author hermit
 * @data 2021/6/23
 * 测试类
 */
@Controller
@RestController
public class TestController {

    private Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    private TestService testService;

    @ApiOperation(value = "用户登录测试接口")
    @GetMapping(value = "/page")
    public ResultBO<TestEntity> selectPage() {
        logger.info("成功调到了分页查询接口");
        Page page = new Page(0, 10);
        page = testService.selectTestPage(page, 0);
        ResultBO resultBO = new ResultBO();
        resultBO.setContent(page);
        resultBO.setCode(666);
        resultBO.setSucceed(true);
        resultBO.setMsg("测试接口返回数据");
        return resultBO;
    }


    @GetMapping(value = "/test")
    public ResultBO<String> testStr() {
        logger.info("成功调到了测试接口");
        ResultBO resultBO = new ResultBO();
        resultBO.setContent("hermit-music-test");
        resultBO.setCode(888);
        resultBO.setSucceed(true);
        resultBO.setMsg("测试接口返回数据");
        return resultBO;
    }
}
